from fastapi import Request

from afast_core.core_plugins.db.peewee_context import db_state_default
from afast_core.core_plugins.pyee_event import EventEmitterPluginClient, NamedEventEmitter


def get_sync_peewee_mysql_plugin_client_producer(request: Request) :
    """
    返回事件处理的客户端对象
    :param request: current request.
    :return: pyee_events producer from the core_app.
    """
    request.app.sync_peewee_mysql._state.set(db_state_default.copy())
    request.app.sync_peewee_mysql.reset()
